<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>

  <body>
    <script>
      function getXHR() {
        var xhr;
        if (window.XMLHttpRequest) {
          xhr = new XMLHttpRequest();
        } else {
          xhr = new ActiveXObjext('Microsoft.XMLHttp');
        }
        return xhr;
      }
      //第一步：创建XMLHttpReques对象
      var ajax = getXHR();
      //第二步：创建请求
      // ajax.open("get", "http://localhost:8000", true);//open发送数据必须是GET请求
      ajax.open('get', 'http://localhost:8000?username=小红&password=1111', true);
      //第三步：发送请求
      ajax.send(null);
      //ajax.send("username=小红&password=1111");//send发送数据一定是POST请求
    </script>
  </body>
</html>
